package com.gr100.biz.app.res;

import cn.dreampie.common.http.HttpRequest;
import cn.dreampie.route.core.Resource;
import cn.dreampie.route.core.annotation.API;
import cn.dreampie.route.core.annotation.GET;
import cn.dreampie.route.core.annotation.POST;
import com.alibaba.fastjson.JSON;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by YFsoft on 16/3/14.
 */
@API("/api/v1.0")
public class ApiResource extends Resource {

    @GET
    public String test() {
        return "ok";
    }

    public String echo(Map<String,Object> result){
        if(result == null){
            result = new HashMap<String,Object>();
            result.put("errno",-999);
            result.put("code","System Error~");
        }else if(!result.containsKey("errno")){
            result.put("errno",0);
        }
        return JSON.toJSONString(result);
    }

    public String echo(String result){
        return result;
    }
}
